//
//  DKUnathorizedFunctionCell.m
//  DanKU
//
//  Created by 吴斌 on 2023/10/24.
//

#import "DKUnathorizedFunctionCell.h"
static NSString * DK_UnauthorizedFunctionCellId = @"DK_UnauthorizedFunctionCellId";

@implementation DKUnathorizedFunctionCell
+ (instancetype)unauthorizedFunctionCell:(UITableView *)tableView{
    DKUnathorizedFunctionCell * dk_UnathorizedFunctionCell = [tableView dequeueReusableCellWithIdentifier:DK_UnauthorizedFunctionCellId];
    if (!dk_UnathorizedFunctionCell) {
        dk_UnathorizedFunctionCell = [[DKUnathorizedFunctionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DK_UnauthorizedFunctionCellId];
    }
    dk_UnathorizedFunctionCell.backgroundColor = [UIColor clearColor];
    dk_UnathorizedFunctionCell.selectionStyle = UITableViewCellSelectionStyleNone;
    dk_UnathorizedFunctionCell.accessoryType = UITableViewCellAccessoryNone;
    return dk_UnathorizedFunctionCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = UIColor.whiteColor;
        self.layer.cornerRadius = DK_IsWidthScale(20);
        self.clipsToBounds = YES;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    WeakSelf(self)
    UIView *UnauthorizedMainBillView = [[UIView alloc] init];
    UnauthorizedMainBillView.backgroundColor = UIColor.whiteColor;
    UnauthorizedMainBillView.layer.cornerRadius = DK_IsWidthScale(20);
    UnauthorizedMainBillView.clipsToBounds = YES;
    [self.contentView addSubview:UnauthorizedMainBillView];
    [UnauthorizedMainBillView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(-DK_IsWidthScale(10)));
    }];
    
    DKUnathorizedSigleView *dk_UnathorizedFAQSigleView = [[DKUnathorizedSigleView alloc] init];
    dk_UnathorizedFAQSigleView.unathorizedSigleType = UnathorizedSigleTypeFAQ;
    [UnauthorizedMainBillView addSubview:dk_UnathorizedFAQSigleView];
    [dk_UnathorizedFAQSigleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(1)));
        make.top.equalTo(@(DK_IsWidthScale(21)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    dk_UnathorizedFAQSigleView.ClickFunBlock = ^{
        if(weakSelf.ClickFunBlock){
            weakSelf.ClickFunBlock(UnathorizedSigleTypeFAQ);
        }
    };
    
    DKUnathorizedSigleView *dk_UnathorizedServiceSigleView = [[DKUnathorizedSigleView alloc] init];
    dk_UnathorizedServiceSigleView.unathorizedSigleType = UnathorizedSigleTypeService;
    [UnauthorizedMainBillView addSubview:dk_UnathorizedServiceSigleView];
    [dk_UnathorizedServiceSigleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_UnathorizedFAQSigleView.mas_right);
        make.top.equalTo(dk_UnathorizedFAQSigleView);
        make.bottom.equalTo(dk_UnathorizedFAQSigleView);
        make.width.equalTo(dk_UnathorizedFAQSigleView);
    }];
    dk_UnathorizedServiceSigleView.ClickFunBlock = ^{
        if(weakSelf.ClickFunBlock){
            weakSelf.ClickFunBlock(UnathorizedSigleTypeService);
        }
    };
    
    DKUnathorizedSigleView *dk_UnathorizedComplaintSigleView = [[DKUnathorizedSigleView alloc] init];
    dk_UnathorizedComplaintSigleView.unathorizedSigleType = UnathorizedSigleTypeSComplaint;
    [UnauthorizedMainBillView addSubview:dk_UnathorizedComplaintSigleView];
    [dk_UnathorizedComplaintSigleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_UnathorizedServiceSigleView.mas_right);
        make.right.equalTo(@(-DK_IsWidthScale(1)));
        make.top.equalTo(dk_UnathorizedFAQSigleView);
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
        make.width.equalTo(dk_UnathorizedServiceSigleView);
    }];
    dk_UnathorizedComplaintSigleView.ClickFunBlock = ^{
        if(weakSelf.ClickFunBlock){
            weakSelf.ClickFunBlock(UnathorizedSigleTypeSComplaint);
        }
    };
}
@end
